package com.juku2024.juku.adapter

import android.widget.ImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.juku2024.juku.R
import com.juku2024.juku.db.entity.FavoriteEntity
import com.juku2024.juku.tools.ImageUtils

class FavoriteAdapter(historyVideoBeans: ArrayList<FavoriteEntity>) :
        BaseQuickAdapter<FavoriteEntity, BaseViewHolder>(R.layout.item_favorite, historyVideoBeans) {

    var isEditStatus = false


    override fun convert(holder: BaseViewHolder, item: FavoriteEntity) {
        val imageView = holder.getView<ImageView>(R.id.ivFavorite)
        ImageUtils.loadImageH(imageView, item.pic)

        holder.setText(R.id.tvNameFavorite, item.name)
//                .setText(R.id.tvPlayEpisodeFavorite, String.format("播放到第%d集", item.episode + 1))
//                .setText(R.id.tvYearFavorite, String.format("年份：%s", item.year?:""))
//                .setText(R.id.tvRoleFavorite, String.format("主演：%s", item.actor?:""))
                .setGone(R.id.edit_button_fl, !isEditStatus)

        val resId = if (item.isSelect) {
            R.drawable.ic_checked
        } else {
            R.drawable.ic_check_normal
        }
        holder.setBackgroundResource(R.id.ivEditFavorite, resId)
    }
}